package com.mt.channel.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.mt.channel.api.service.IChannelCustomerService;
import com.mt.channel.entity.ChannelCustomerEntity;
import com.mt.common.PagerInfo;
import com.mt.common.ServiceResult;
@CrossOrigin
@RestController
public class ChannelCustomerController {

    @Autowired
    IChannelCustomerService channelCustomerService;

    @GetMapping("/channelCustomer/findList/{page}/{size}")
    public ServiceResult<List<ChannelCustomerEntity>> findList(@RequestParam Map<String, Object> params,
        @PathVariable(value = "page") Integer page, @PathVariable(value = "size") Integer size) {
        PagerInfo pagerInfo = null;
        if(page >0 && size>0){
            pagerInfo=new PagerInfo();
            pagerInfo.setPageIndex(page);
            pagerInfo.setPageSize(size);
        }
        return channelCustomerService.findList(params, pagerInfo);


    }
    @GetMapping("/channelCustomer/findInfo")
    public ServiceResult<ChannelCustomerEntity> findInfo(@RequestParam Map<String, Object> params) {
        return channelCustomerService.findInfo(params);
    }

    @PostMapping("/channelCustomer/doInsert")
    public ServiceResult<Integer> doInsert(@RequestBody ChannelCustomerEntity channelCustomerEntity) {
        return channelCustomerService.doInsert(channelCustomerEntity);
    }

    @PostMapping("/channelCustomer/doUpdate")
    public ServiceResult<Integer> doUpdate(@RequestBody ChannelCustomerEntity channelCustomerEntity) {
        return channelCustomerService.doUpdate(channelCustomerEntity);
    }



}
